


cc.Class({
    extends: cc.Component,

    properties: {
     picture:[cc.SpriteFrame],
    },

   

     onLoad () {
      this.speedx = 0;
      this.speedy = 0;
      this.speed = 10;
     },

    start () {

    },


    init:function(rotation,type){
      
    this.node.getComponent(cc.Sprite).spriteFrame = this.picture[type];
     this.node.rotation = rotation;
     var radian = rotation * Math.PI /180;
     this.speedx = Math.sin(radian)*this.speed;
     this.speedy = Math.cos(radian)*this.speed;
    
    },

    die:function(){
      this.node.destroy();
    },

    update (dt) {
    
      this.node.x += this.speedx;  
      this.node.y += this.speedy;
      

      var position = this.node.convertToWorldSpaceAR();
      if(position.x <= 0 || position.x >= cc.winSize.width || position.y <= 0 || position.y >= cc.winSize.height){
          this.node.destroy();
      }

    },
});
